<!DOCTYPE html>
<html style="background-attachment: fixed;">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>设备详情页</title>
    <meta name="description" itemprop="description" content="新国都日志管理后台">
    <meta name="keywords" content="新国都,日志,管理,后台">
    <meta name="generator" content="皮皮华">
    <meta name="author" content="皮皮华">
    <meta name="copyright" content="huazai.eleuu.com">
    <link rel="shortcut icon" href="static/favicon.ico" type="image/x-icon">
    <link href="static/style/common.css?ver=4.40" rel="stylesheet">
    <link href="static/style/font-awesome/css/font-awesome.css?ver=4.40" rel="stylesheet">
    <link href="static/style/wap/app_explorer.css?ver=4.40" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.3.3/echarts.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
</head>

<body>

<div id="DrvInfo" style="width: 600px;margin:auto;"></div>
<!-- 为 ECharts 准备一个定义了宽高的 DOM -->
<div id="main" style="width: 600px;height:400px;margin:auto;"></div>
<script type="text/javascript">
    var SIMStatuStr = [
        "","参数初始化","等待启动","模块初始化","获取模块信息",
        "获取SIM卡状态","获取SIM卡信息","寻网中","入网失败","入网成功",
        "开始拨号","正在拨号","拨号成功","停止拨号",
    ];
    //获取url中的参数
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]); return null; //返回参数值
    }
    function showCSQ(csqData) {
        // 基于准备好的dom，初始化echarts实例,第二个参数可以指定前面引入的主题
        var myChart = echarts.init(document.getElementById('main'));
        // 指定图表的配置项和数据
        var option = {
            title: {
                //text: '信号强度'
            },
            tooltip: {},
            legend: {
                data: ['信号强度']
            },
            xAxis: {
                type: 'category',
                name: "时间",
                axisLine: {
                    lineStyle: {
                        color: '#ccc'
                    }
                },
                data: csqData.csq_time
            },
            yAxis: {
                type: 'value',
                name: "信号强度",
                splitLine: { show: true },
                axisLine: {
                    lineStyle: {
                        color: '#ccc'
                    }
                }
            },
            series: [
                {
                    type: 'line',
                    name: "信号强度",
                    smooth: true,
                    showAllSymbol: true,
                    symbol: 'emptyCircle',
                    symbolSize: 15,
                    data: csqData.csq_val
                }
            ]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }
    //获取设备信息
    function GetDrvInfo(){
        $.ajax({
            type: "GET",
            url: "/xgd",
            data: "action=get_drv_info&sn="+getUrlParam("sn"),
            dataType : "json",
            success: function(jsonData){
                console.log(jsonData);
                if (jsonData.err_code === 0){
                    var drvData = jsonData.data.drv_info;
                    var csqPercent = (drvData.csq*100/31).toFixed(0);
                    var csqStr = "";
                    if(drvData.csq <= 11){
                        csqStr = "较差";
                    }else if(drvData.csq > 11 && drvData.csq <= 18){
                        csqStr = "一般";
                    }else if(drvData.csq > 18 && drvData.csq <= 25){
                        csqStr = "良好";
                    }else if(drvData.csq > 25){
                        csqStr = "极好";
                    }
                    var htmlstr = '<h3>设备SN号: '+drvData.sn+'</h3>'
                        +'<h3>设备时间: '+drvData.drv_time+'</h3>'
                        +'<h3>SIM卡状态: '+drvData.sim_status+' ('+SIMStatuStr[drvData.sim_status]+')'+'</h3>'
                        +'<h3>信号强度: '+drvData.csq+' ('+csqPercent+'% '+csqStr+')'+'</h3>'
                        +'<h3>信噪比: '+drvData.rate+'</h3>'
                        +'<h3>IMEI: '+drvData.imei+'</h3>'
                        +'<h3>IMSI: '+drvData.imsi+'</h3>'
                        +'<h3>ICCID: '+drvData.iccid+'</h3>'
                        +'<h3>手机号: '+drvData.phone_num+'</h3>'
                        +'<h3>BOOT版本号: '+drvData.boot_ver+'</h3>'
                        +'<h3>底层内核版本: '+drvData.core_ver+'</h3>'
                        +'<h3>TE测试程序版本号: '+drvData.te_ver+'</h3>'
                        +'<h3>模组类型: '+drvData.mod_type+'</h3>'
                        +'<h3>模组版本: '+drvData.mod_ver+'</h3>'
                        +'<h3>模组SDK版本: '+drvData.mod_sdk_ver+'</h3>'
                        +'<h3>模组内核版本: '+drvData.mod_core_ver+'</h3>'
                        +'<h3>工厂模式: '+drvData.factory_mode+'</h3>'

                        +'<h3>数据获取时间: '+drvData.update_time+'</h3>';
                    $("#DrvInfo").html(htmlstr);
                    showCSQ(jsonData.data.csq);
                }
            }
        });
    }
    //加载页面完成
    $(document).ready(function() {
        GetDrvInfo();
    });
</script>
</body>

</html>